﻿using System;
using System.Windows.Automation;

namespace QuickUIT.Controls
{
    /// <summary>
    /// Represents a data item type control. 
    /// </summary>
    public class UIDataItem : UIBaseControl
    {
        /// <summary>
        /// Specifies the ordinal number of the column that contains this cell or item.
        /// If the control does not support the <see cref="GridItemPattern"/>, returns -1. 
        /// </summary>
        public new int Column
        {
            get { return base.Column; }
        }

        /// <summary>
        /// Specifies the number of columns spanned by this cell or item.
        /// If the control does not support the <see cref="GridItemPattern"/>, returns -1. 
        /// </summary>
        public new int ColumnSpan
        {
            get { return base.ColumnSpan; }
        }

        /// <summary>
        /// Specifies the ordinal number of the row that contains this cell or item.
        /// If the control does not support the <see cref="GridItemPattern"/>, returns -1. 
        /// </summary>
        public new int Row
        {
            get { return base.Row; }
        }

        /// <summary>
        /// Specifies the number of rows spanned by this cell or item.
        /// If the control does not support the <see cref="GridItemPattern"/>, returns -1. 
        /// </summary>
        public new int RowSpan
        {
            get { return base.RowSpan; }
        }
        
        /// <summary>
        /// Gets the expand/collapse state of the item, if the data item can be expanded or collapse to hide information. 
        /// If the control does not support the <see cref="ExpandCollapsePattern"/> , a null reference is returned.
        /// </summary>
        public new ExpandCollapseState? ExpandCollapseState
        {
            get { return base.ExpandCollapseState; }
        }

        /// <summary>
        /// Gets the toggle state of the item, if the data item contains a state that can be cycled through. 
        /// If the control does not support the <see cref="ToggleState"/> , a null reference is returned.
        /// </summary>
        public new ToggleState? ToggleState
        {
            get { return base.ToggleState; }
        }

        /// <summary>
        /// Gets whether the data item is expanded, if the data item can be expanded or collapse to hide information. 
        /// </summary>
        public bool IsExpanded
        {
            get
            {
                return (ExpandCollapseState.HasValue &&
                        ExpandCollapseState.Value == System.Windows.Automation.ExpandCollapseState.Expanded); 
            }
        }

        /// <summary>
        /// Gets whether the data item is selected, if the data item can be selected. 
        /// </summary>
        public new bool IsSelected
        {
            get { return base.IsSelected; }
        }

        /// <summary>
        /// Gets or sets the value of the data item, if the data item's primary text is editable. 
        /// </summary>
        public new string Value
        {
            get { return base.Value; }
            set { SetValue(value); }
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIDataItem"/> class. 
        /// </summary>
        public UIDataItem() : base(ControlType.DataItem)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIDataItem"/> class.
        /// </summary>
        /// <param name="parent">The parent of this control.</param>
        public UIDataItem(UIBaseControl parent) : base(parent, ControlType.DataItem)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIDataItem"/> class.
        /// </summary>
        /// <param name="locator">The locator used to find the specific control.</param>
        public UIDataItem(string locator) : base(null, ControlType.DataItem, locator)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIDataItem"/> class.
        /// </summary>
        /// <param name="parent">The parent of this control.</param>
        /// <param name="locator">The locator used to find the specific control.</param>
        public UIDataItem(UIBaseControl parent, string locator) : base(parent, ControlType.DataItem, locator)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIDataItem"/> class.
        /// </summary>
        /// <param name="control">The underlying <see cref="AutomationElement"/> of the control.</param>
        public UIDataItem(AutomationElement control) : base(control, ControlType.DataItem)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIDataItem"/> class.
        /// </summary>
        /// <param name="parent">The parent of the control</param>
        /// <param name="control">The underlying <see cref="AutomationElement"/> of the control.</param>
        public UIDataItem(UIBaseControl parent, AutomationElement control) : base(parent, control, ControlType.DataItem)
        {
        }

        /// <summary>
        /// Toggles the data item, if the data item contains a state that can be cycled through. 
        /// </summary>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The element is not available anymore.</exception>
        /// <remarks>A control will cycle through its <see cref="ToggleState"/> in this order: On, Off and, if supported, Indeterminate.</remarks>
        public new void Toggle()
        {
            base.Toggle();
        }

        /// <summary>
        /// Toggles on the data item, if the data item contains a state that can be cycled through. 
        /// </summary>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The element is not available anymore.</exception>
        public new void ToggleOn()
        {
            base.ToggleOn();
        }

        /// <summary>
        /// Toggles off the data item, if the data item contains a state that can be cycled through. 
        /// </summary>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The element is not available anymore.</exception>
        public new void ToggleOff()
        {
            base.ToggleOff();
        }

        /// <summary>
        /// Expands the current data item if it can be expanded or collpased to show show and hide information. 
        /// </summary>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The element is not available anymore.</exception>
        public new void Expand()
        {
            base.Expand();
        }

        /// <summary>
        /// Expands the current data item if it can be expanded or collpased to show show and hide information. 
        /// </summary>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The element is not available anymore.</exception>
        public new void Collapse()
        {
            base.Collapse();
        }

        /// <summary>
        /// Deselects any selected items and then selects the current data item.
        /// </summary>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The element is not available anymore.</exception>
        public new void Select()
        {
            base.Select();
        }

        /// <summary>
        /// Adds the current data item to the collection of selected items. 
        /// </summary>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The element is not available anymore.</exception>
        public new void AddToSelection()
        {
            base.AddToSelection();
        }

        /// <summary>
        /// Removes the current data item to the collection of selected items. 
        /// </summary>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The element is not available anymore.</exception>
        public new void RemoveFromSelection()
        {
            base.RemoveFromSelection();
        }

        /// <summary>
        /// Scrolls the data item into view if the data container has more items than can fit onscreen. 
        /// </summary>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The element is not available anymore.</exception>
        public new void ScrollIntoView()
        {
            base.ScrollIntoView();
        }

        /// <summary>
        /// Gets the container of a cell or item. 
        /// </summary>
        /// <returns>An <see cref="AutomationElement"/> that represents the container of a cell or item.</returns>
        /// <exception cref="InvalidOperationException">The pattern is not supported by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The element is not available anymore.</exception>
        public new AutomationElement GetContainingGrid()
        {
            return base.GetContainingGrid();
        }

        /// <summary>
        /// Gets the parent selection container of a control. 
        /// </summary>
        /// <returns>The <see cref="AutomationElement"/> of the parent control that implements the <see cref="SelectionPattern"/>.</returns>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The element is not available anymore.</exception>
        public new AutomationElement GetSelectionContainer()
        {
            return base.GetSelectionContainer(); 
        }

        /// <summary>
        /// Gets a collection of elements that represents all the column headers in a table.
        /// </summary>
        /// <returns>A collection of elements representing the column headers.</returns>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The element is not available anymore.</exception>
        public new AutomationElement[] GetColumnHeaderItems()
        {
            return base.GetColumnHeaderItems();
        }

        /// <summary>
        /// Gets a collection of row headers associated with a table item or cell. 
        /// </summary>
        /// <returns>A collection of elements representing the column headers.</returns>
        /// <exception cref="InvalidOperationException">The pattern is not supported by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The element is not available anymore.</exception>
        public new AutomationElement[] GetRowHeaderItems()
        {
            return base.GetRowHeaderItems(); 
        }

        /// <summary>
        /// Sets the value of the data item, if the item's primary text is editable. 
        /// </summary>
        /// <param name="value">The string to be inserted.</param>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The element is not available anymore.</exception>
        public new void SetValue(string value)
        {
            base.SetValue(value);
        }
    }
}
